import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import set from '@dfeidao/atom-mobile/local/set';
import nodejs from '@dfeidao/atom-mobile/msg/nodejs';
import render from '@dfeidao/atom-mobile/render/render';
import whoami_getparams from '../atom/whoami_getparams';

export default async function a001(fd: IFeidaoAiMobile) {
	// 初始
	const user = await whoami_getparams(fd) as {
		params: {
			teacher_name: string;
			productid: string;
			teacher_no: string;
		}
	};
	const teacher_no = user.params.teacher_no;
	const productid = user.params.productid;
	const class_res = await nodejs<[{ class_id: string, grade: string, class_name: string }]>('app-home/s001', {
		params: {
			productid,
			teacher_no
		}
	});
	const d = await nodejs('app-home/s002', {
		params: {
			productid,
			teacher_no,
			class_id: class_res[0].class_id,
			class_res
		}
	});
	render(fd, { data: { class_res, d, vaue_name: class_res[0].grade + class_res[0].class_name, vaue: class_res[0].class_id, id: class_res[0].class_id } });
	set(fd, 'class_res', class_res);
	set(fd, 'vaue', class_res[0].class_id);
	set(fd, 'params', user.params);
}
